package priv.wangy.micro.common.po.http.rspn;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import priv.wangy.micro.common.po.http.rspn.code.IHttpRspnEnum;
import priv.wangy.micro.common.po.http.rspn.view.DefaultView;

/**
 * HTTP公共响应报文结构
 *
 * @author 张嘉琪
 * @since 2022-01-28
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonView(DefaultView.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
@EqualsAndHashCode(callSuper = true)
public class FullHttpResponse<T> extends BaseHttpResponse {

    /**
     * 响应json数据
     */
    private T rspnJson;

    public FullHttpResponse(IHttpRspnEnum rspn) {
        super(rspn);
    }

    public void normalSuccess(T t) {
        normalSuccess();
        this.rspnJson = t;
    }

    public void success(T t, String rspnCode, String rspnMsg) {
        success(rspnCode, rspnMsg);
        this.rspnJson = t;
    }


    public void success(T t, IHttpRspnEnum rspn) {
        success(rspn);
        this.rspnJson = t;
    }

    public void failure(T t, String rspnCode, String rspnMsg) {
        failure(rspnCode, rspnMsg);
        this.rspnJson = t;
    }


    public void failure(T t, IHttpRspnEnum rspn) {
        failure(rspn);
        this.rspnJson = t;
    }


}
